﻿using UnityEngine;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using UnityEngine.UI;

namespace ZXthex.Html
{
    public static class HTML2UGUI
    {
        public static void FromHtmlFlieToUI(string path, RectTransform uiContainer)
        {
            HtmlDocument doc = new HtmlDocument();
            doc.LoadFrom(path);

            CSSStyleSheet css = new CSSStyleSheet();
            css.LoadFrom(doc);

            RenderHtmlDocument rdoc = new RenderHtmlDocument(doc, css);

            UGUIHtml_Builder b = new UGUIHtml_Builder(rdoc, uiContainer);
            UGUI_HtmlDocument udoc = b.GenerateUGUI();
        }

        public static void HtmlToUI(string html, RectTransform uiContainer)
        {
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(html);

            CSSStyleSheet css = new CSSStyleSheet();
            css.LoadFrom(doc);

            RenderHtmlDocument rdoc = new RenderHtmlDocument(doc, css);

            UGUIHtml_Builder b = new UGUIHtml_Builder(rdoc, uiContainer);
            UGUI_HtmlDocument udoc = b.GenerateUGUI();
        }
        
    }
}